#pragma once
#include "OGLRenderer.h"

enum MeshBuffer{
	VERTEX_BUFFER, COLOUR_BUFFER, TEXTURE_BUFFER, NORMAL_BUFFER, TANGENT_BUFFER, INDEX_BUFFER, MAX_BUFFER
};

class Mesh{
public:
	static Mesh*	GenerateQuad();
	static Mesh *	GenerateHP ();

	Mesh(void);
	virtual ~Mesh();

	virtual void	Draw();
	static Mesh*	GenerateTriangle();
	const GLuint getBufferObject(MeshBuffer m) const { return bufferObject[m]; }
	void	SetTexture(GLuint tex)	{ texture = tex;  }
	GLuint	GetTexture()		{ return texture; }

	void SetBumpMap(GLuint tex)	{bumpTexture = tex;}
	GLuint GetBumpMap()			{return bumpTexture;}

	void	SetTexture2(GLuint tex)	{ texture2 = tex;  }
	GLuint	GetTexture2()			{ return texture2; }

	void SetBumpMap2(GLuint tex)	{bumpTexture2 = tex;}
	GLuint GetBumpMap2()			{return bumpTexture2;}

	Vector3* GetVerticies()		{return vertices;}
	int		  GetNumVerticies()		{return numVertices;}
	Vector3* GetNormals()			{return normals;}

protected:
	void			BufferData();
	void			GenerateNormals();

	void			GenerateTangents();
	Vector3			GenerateTangent(const Vector3 &a, const Vector3 &b,
									const Vector3 &c, const Vector2 &ta,
									const Vector2 &tb, const Vector2 &tc);

	Vector3*		tangents;
	GLuint			bumpTexture;
	GLuint			bumpTexture2;

	GLuint			numIndices;
	unsigned int*	indices;
	GLuint			arrayObject;
	GLuint			bufferObject[MAX_BUFFER];
	GLuint			numVertices;
	GLuint			type;
	GLuint			texture;
	GLuint			texture2;

	Vector3*		vertices;
	Vector4*		colours;
	Vector2*		textureCoords;
	Vector3*		normals;
};